use tokio::fs;

use crate::error::IoErr;

#[cfg(debug_assertions)]
pub const MY_SQL_URL: &'static str = env!("DATABASE_URL");

#[cfg(not(debug_assertions))]
pub const MY_SQL_URL: &'static str = "mysql://ttt:root@127.0.0.1/db_bread";

pub const HTTP_ADDR: &'static str = "[::]:4000";
pub const HTTP_ADDR_V4: &'static str = "0.0.0.0:4000";

pub const HTML_DIR: &'static str = "./data/html";
pub const FIRM_DIR: &'static str = "./data/firm";
pub const ADV_DIR: &'static str = "./data/adv";

pub async fn init() -> Result<(), IoErr> {
    fs::create_dir_all(HTML_DIR).await?;
    fs::create_dir_all(FIRM_DIR).await?;
    fs::create_dir_all(ADV_DIR).await?;
    Ok(())
}
